package com.asiainfo.iyoga.service;

import com.asiainfo.iyoga.dao.MemberDao;
import com.asiainfo.iyoga.dao.TimeCardDAO;
import com.asiainfo.iyoga.dao.YearCardDAO;
import com.asiainfo.iyoga.model.Member;
import com.asiainfo.iyoga.model.TimeCard;
import com.asiainfo.iyoga.model.YearCard;

public class MemberService {
	public MemberService() {
		
	}

	public boolean addMember(Member member) {
		String feedback = "";
		boolean flag;
		MemberDao memdao = new MemberDao();
		flag = memdao.addMember(member);
		if(flag)
		{
			feedback = "OK." + member.getStrName() + "'s member id is ";
			int n = getIdByName(member.getStrName());
			System.out.println(feedback + n);
		}
		return flag;
	}
	
	public int getIdByName(String name) {
		int res;
		MemberDao memdao = new MemberDao();
		res = memdao.getIdByName(name);
		return res;
	}
	
	public boolean addYearCard(YearCard yearcard) {
		String feedback = "";
		boolean flag;
		YearCardDAO yearCardDao = new YearCardDAO();
		flag = yearCardDao.addCard(yearcard);
//		if(flag)
//		{
//			feedback = "OK." + member.getStrName() + "'s member id is ";
//			int n = getIdByName(member.getStrName());
//			System.out.println(feedback + n);
//		}
		return flag;
	}
	
	public boolean addTimeCard(TimeCard timecard) {
		boolean flag;
		TimeCardDAO timeCardDao = new TimeCardDAO();
		flag = timeCardDao.addCard(timecard);
		return flag;
	}
}
